package com.zhaojk.audio.service;

import com.zhaojk.audio.entity.Word;
import com.zhaojk.audio.mapper.WordMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WordService {
    private final WordMapper wordMapper;

    public WordService(WordMapper wordMapper) {
        this.wordMapper = wordMapper;
    }

    public Word getWordById(Long id) {
        return wordMapper.findById(id);
    }

    public List<Word> getAllWords() {
        return wordMapper.findAll();
    }

    public void addWord(Word word) {
        wordMapper.insert(word);
    }

    public void updateWord(Word word) {
        wordMapper.update(word);
    }

    public void deleteWord(Long id) {
        wordMapper.delete(id);
    }
}
